﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace ProcessesSMS
{
    public partial class FormTestCode : Form
    {
        public FormTestCode()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string tmpMsg = textBox1.Text;
            string[] msg = tmpMsg.Split(new char[] { ' ' });           
               label1.Text = GetReturnMsg(msg);            
            return;
        }
        private bool checkIsNumber(string txNumber)
        {
            bool textIsNumeric = true;
            try
            {
                int.Parse(txNumber.Trim());
            }
            catch
            {
                textIsNumeric = false;
            }
            return textIsNumeric;
        }
        private string GetReturnMsg(string[] arr)
        {
            string msgBody = string.Empty;
            string sbd = arr[0];
            int slbc = 0;
            try
            {
                 slbc = int.Parse(arr[1]);
            }
            catch { return "Loi cu phap!Luot binh chon phai la so"; }
            string name = "";
            DataSet ds = new DataSet();
            ds.ReadXml("D:\\WORKSPACE\\Projects\\Backup SMS\\ProcessSMS\\bin\\Release\\DS_VOTE.xml");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i]["SBD"].ToString() == arr[0])
                {
                    name = ds.Tables[0].Rows[i]["NAME"].ToString();
                    break;
                }
            }
            if (string.IsNullOrEmpty(name))
            {
                msgBody = "Khong ton tai thi sinh co so bao danh " + sbd;
            }
            else
            {
                msgBody = "Cam on bạn da binh chọn cho thi sinh " + name.ToUpper() + " voi luot binh chon " + slbc.ToString() + ".Chuc ban may man!";
            }
            return msgBody;
        }
    }
}
